package com.tencreat.common.core.config;

import com.tencreat.common.core.enums.AccessPolicyType;
import com.tencreat.common.core.utils.SpringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/**
 * 文件上传Factory
 *
 * @author zixin
 */
@Slf4j
public class OssFactory {

    private static OssClient OSS_CLIENT = null;


    /**
     * 获取默认实例
     */
    public static OssClient instance() {
        // 获取redis 默认类型
        if (OSS_CLIENT == null) {
            OssProperties properties = SpringUtils.getBean(OssProperties.class);
            properties.setIsHttps("N");
            properties.setAccessPolicy(AccessPolicyType.PUBLIC.getType());
            OSS_CLIENT = new OssClient(properties);
        }
        return OSS_CLIENT;
    }

}
